<?php
/*******************************************************************************
 * 3 column dashboard
 * 3 column replacement riverdashboard wire input on dashboard
 *
 * @package 3 column dashboard
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
 * @author Fusion <contact@donkeydesigns.us>
 * @copyright TheFloridaCircle.com 2008-2009
 * @link http://www.thefloridacircle.com/
 *
 ******************************************************************************/

	 //grab the users latest from the wire
	 
	$latest_wire = get_entities("object", "thewire", $_SESSION['user']->guid, "", 1, 0, false, 0, null); 
	if($latest_wire){
		foreach($latest_wire as $lw){
			$content = $lw->description;
			$time = "<span> (" . friendly_time($lw->time_created) . ")</span>";
		}
	}
	$wire_user = get_input('wire_username');
	if (!empty($wire_user)) { $msg = '@' . $wire_user . ' '; } else { $msg = ''; }

?>

<script>
function textCounter(field,cntfield,maxlimit) {
    // if too long...trim it!
    if (field.value.length > maxlimit) {
        field.value = field.value.substring(0, maxlimit);
    } else {
        // otherwise, update 'characters left' counter
        cntfield.value = maxlimit - field.value.length;
    }
}
</script>
<script type = "text/javascript">
var count = 0;
function changeCol(which) {
	which.style.color = '#000000';
	if(count == 0) {
		which.value = "";  // erase text only on first focus
		count ++;
	}
}
</script>
<div id="river_container2">
<div class="dash_pad">
<div class="sidebarBox">

		<form action="<?php echo $vars['url']; ?>action/thewire/add" method="post" name="noteForm">
			<?php echo "<div class='thewire_latest1'><b>" . elgg_echo('thewire:latest') .":</b> " . $content . " " . $time . "</div><div class='clearfloat'></div>"; ?>	
			<?php
				$display .= "<div class='thewire_characters_remaining'><input readonly type=\"text\" name=\"remLen1\" size=\"3\" maxlength=\"3\" value=\"140\" class=\"thewire_characters_remaining_field\">";
			    $display .= elgg_echo("thewire:charleft") . "</div>";
	            $display .= "<h3>" . elgg_echo('river:newpost') . "</h3>";
			
			    $display .= "<textarea name='note' value='' onKeyDown=\"textCounter(document.noteForm.note,document.noteForm.remLen1,140)\" onKeyUp=\"textCounter(document.noteForm.note,document.noteForm.remLen1,140)\" id=\"thewire_sidebarInputBox\" onfocus =\"changeCol(this)\">{$msg}".elgg_echo('river:newpost')."</textarea>";
				
			    echo $display;
				
			?>
				<input type="hidden" name="method" value="site" />
				<input type="hidden" name="location" value="activity" />
	            <div style="float:right; width:40px;">
	            	<input type="submit" value="<?php echo elgg_echo('Post'); ?>" id="thewire_submit_button" />
	            </div>
		</form>
            
            <div id="atticons">
            <h4 style="float:left; padding:3px 3px 0 0; color:#666666;">Add:</h4>
            <?php if (is_plugin_enabled('tidypics')){ ?>
            <a href="<?php echo $vars['url']; ?>pg/photos/new/<?php echo $_SESSION['user']->username; ?>"><img src="<?php echo $vars['url']; ?>mod/riverdashboard/graphics/icon_image.png" title="Add a Photo" /></a>
            <?php } ?>
            
            <?php if (is_plugin_enabled('izap_videos')){ ?>
            <a href="<?php echo $vars['url']; ?>pg/izap_videos/<?php echo $_SESSION['user']->username; ?>/add/?handler=izap_videos&page=<?php echo $_SESSION['user']->username; ?>"><img src="<?php echo $vars['url']; ?>mod/riverdashboard/graphics/icon_video.png" title="Add a Video" /></a>
            <?php } ?>
        
            <?php if (is_plugin_enabled('event_calendar')){ ?>
            <a href="<?php echo $vars['url']; ?>pg/event_calendar/new/"><img src="<?php echo $vars['url']; ?>mod/riverdashboard/graphics/icon_event.png" title="Add an Event" /></a>
            <?php } ?>
            
            <?php if (is_plugin_enabled('poll')){ ?>
            <a href="<?php echo $vars['url']; ?>mod/poll/add.php"><img src="<?php echo $vars['url']; ?>mod/riverdashboard/graphics/polls.png" title="Add a Poll" /></a>
            <?php } ?>
        
            <?php if (is_plugin_enabled('gifts')){ ?>
            <a href="<?php echo $vars['url']; ?>pg/gifts/<?php echo $_SESSION['user']->username; ?>/sendgift"><img src="<?php echo $vars['url']; ?>mod/riverdashboard/graphics/icon_gift.png" title="Send a Gift" /></a>
            <?php } ?>
            </div>
        
	<div class="clearfloat"></div>
</div><!-- /sidebarboy -->
</div><!--  /Dashpad -->

<?php echo elgg_view('input/urlshortener'); ?>
</div><!-- /Rivercontainer2 -->